﻿using UnityEngine;
using System.Collections;

public class maskTesting : MonoBehaviour 
{
    static int pixelCount = 1280 * 720;
    public Texture2D maskTexture;
    
    public Color[] alphaColorArray;
    public Material mat;
	
	void Start()
    {
        alphaColorArray = WorldmapDataMgr.GetPixelAlpha(0);
        //alphaColorArray = new Color[pixelCount];
//         for (int i = 0; i < (pixelCount/4 ); ++i)
//         {
//             alphaColorArray[i] = Color.white;
//         }
        
        //maskTexture = new Texture2D(1280, 720);
                
        alphaColorArray = maskTexture.GetPixels();

        for (int i = 0; i < alphaColorArray.Length; ++i)
        {
            if (alphaColorArray[i].a > 0)
                alphaColorArray[i].a = 1.0f;

        }

        WorldmapDataMgr.SetPixelAlpha(0, alphaColorArray);
        //maskTexture.SetPixels(alphaColorArray);
        //maskTexture.Apply();
        
        mat.SetTexture("_AlphaTex", maskTexture);
	}

    public void UpdatePixel()
    {
        maskTexture.SetPixels(alphaColorArray);
        maskTexture.Apply();
    }
}